<%@ page language="java" pageEncoding="utf-8" %>
<%--<%@taglib uri="/struts-tags" prefix="s"%>--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

    <title>My JSP 'ProblemSolve.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--favicon-->
    <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">
    <!-- simplebar CSS-->
    <link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet"/>
    <!-- Bootstrap core CSS-->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
    <!-- animate CSS-->
    <link href="assets/css/animate.css" rel="stylesheet" type="text/css"/>
    <!-- Icons CSS-->
    <link href="assets/css/icons.css" rel="stylesheet" type="text/css"/>
    <!-- Sidebar CSS-->
    <link href="assets/css/sidebar-menu.css" rel="stylesheet"/>
    <!-- Custom Style-->
    <link href="assets/css/app-style.css" rel="stylesheet"/>
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

</head>

<body>
<div class="container-fluid">
    <!-- Breadcrumb-->
    <div>
        <form action="findSolve" class="search-bar" style="width: 340px;">
            <input type="text" name="name" class="form-control" placeholder="请输入你要搜索的问题">
            <button id="ss" type="submit" value="搜索" style="display: none;"/>
            搜索</button>


            <a href="javascript:find()"><i class="icon-magnifier"></i></a>
        </form>
    </div>

    <hr>
    <!--
        描述：第一行
    -->
    <div class="row">
        <!--
            描述：问题模板一蓝色
        -->

        <c:forEach items="${solveData}" var="solve">
            <c:choose>
                <c:when test="${solve.issolve==1}">
                    <div class="col-lg-6">
                        <div class="card">
                            <div class="card-body">
                                <ul class="nav nav-tabs bg-facebook shadow-facebook">
                                    <li class="nav-item">
                                        <a class="nav-link active" data-toggle="tab" href="#t${solve.sid}-1"><i
                                                class="icon-home"></i> <span
                                                class="hidden-xs">问题名：${solve.name}</span></a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link" data-toggle="tab" href="#t${solve.sid-2}"><i
                                                class="icon-user"></i> <span
                                                class="hidden-xs">问题内容:${solve.proContent}</span></a>
                                    </li>
                                    <li>
                                        <button type="button" class="btn btn-warning waves-effect waves btn-sm"
                                                style="margin: 0px auto;" onclick="sweet('${solve.sid}')">删除
                                        </button>
                                    </li>
                                </ul>
                                <!-- Tab panes -->

                                <div class="tab-content">
                                    <input type="hidden" name="solve.sid" value='${solve.sid}'/>

                                    <div id="t${solve.sid-1}" class="container tab-pane active">
                                        回答：${solve.prodescript}
                                        <p></p>
                                    </div>
                                    <div id="t${solve.sid-1}" class="container tab-pane fade">
                                        问题内容：${solve.proContent}
                                        <p></p>
                                    </div>


                                </div>
                            </div>
                        </div>
                    </div>
                </c:when>
                <c:when test="${solve.issolve==0}">
                    <div class="col-lg-6">
                        <div class="card">
                            <div class="card-body">
                                <ul class="nav nav-tabs bg-facebook shadow-facebook">
                                    <li class="nav-item">
                                        <a class="nav-link active" data-toggle="tab" href="#tabe-1"><i
                                                class="icon-home"></i> <span class="hidden-xs">问题内容</span></a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link" data-toggle="tab" href="#tabe-2"><i class="icon-user"></i>
                                            <span
                                                    class="hidden-xs">回答内容</span></a>
                                    </li>
                                </ul>
                                <!-- Tab panes -->

                                <div class="tab-content">
                                    <div id="tabe-1" class="container tab-pane active">
                                        问题：暂无问题被解答
                                        <p></p>
                                    </div>
                                    <div id="tabe-2" class="container tab-pane fade">
                                        <p></p>
                                    </div>
                                    <div id="tabe-2" class="container tab-pane fade">
                                        <p>该问题暂无人解答</p>
                                        <p></p>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </c:when>
            </c:choose>
        </c:forEach>
        <!--
        描述：模板结束
        -->
        <c:if test="${solve.issolve==0}">
            <div class="col-lg-6">
                <div class="card">
                    <div class="card-body">
                        <ul class="nav nav-tabs bg-facebook shadow-facebook">
                            <li class="nav-item">
                                <a class="nav-link active" data-toggle="tab" href="#tabe-1"><i
                                        class="icon-home"></i>
                                    <span class="hidden-xs">问题内容</span></a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" data-toggle="tab" href="#tabe-2"><i class="icon-user"></i> <span
                                        class="hidden-xs">回答内容</span></a>
                            </li>
                            <li>
                                <button type="button" class="btn btn-warning waves-effect waves btn-sm"
                                        style="margin: 0px auto;" onclick="sweet('${solve.sid}')">删除
                                </button>
                            </li>
                        </ul>
                        <!-- Tab panes -->

                        <div class="tab-content">
                            <div id="tabe-1" class="container tab-pane active">
                                问题：暂无问题被解答
                                <p></p>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </c:if>


    </div>
</body>
<!-- Bootstrap core JavaScript-->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>

<!-- simplebar js -->
<script src="assets/plugins/simplebar/js/simplebar.js"></script>
<!-- sidebar-menu js -->
<script src="assets/js/sidebar-menu.js"></script>

<script src="assets/plugins/alerts-boxes/js/sweetalert.min.js"></script>
<script src="assets/plugins/alerts-boxes/js/sweet-alert-script.js"></script>
<!-- Custom scripts -->
<script src="assets/js/app-script.js"></script>
<script type="text/javascript">
    function find() {
        document.getElementById("ss").click();
    }
    function sweet(data) {
        swal({
            title: "您确定吗?",			//弹出标题
            text: "该操作会删除该问题!",			//弹出文本
            icon: "info",				//警告图标   还有success error  info  不填就是不显示，默认不显示
            buttons: true,
            dangerMode: true,
        })
            .then((willDelete) => {
                if (willDelete) {
                    console.log(data)
                    swal("你的问题已删除!", {
                        icon: "success",
                    });
                    console.log("1")
                    $.ajax({
                        url: "delSolve?sid=" + data,
                        dataType: 'json',
                        type: "get",

                        error: function (res) {
                            console.log("er",res)
                        },
                        success:function(res){
                            window.location.href="./SolveDel"
                            console.log("su",res)
                        }
                    })


                    //嵌成果方法
                } else {
                    swal("问题删除失败!");
                    //嵌失败方法
                }
            });
    }
</script>
</html>
